﻿namespace GXRTBTC.WebHisDataService.Model
{
    public class DevHisRecord
    {
        /// <summary>
        /// 工位号
        /// </summary>
        public string positionId { get; set; } = "";
        public string devType { get; set; } = "";
        /// <summary>
        /// 存储方式，默认3
        /// 0：所有（每秒）；
        /// 1：每分钟；
        /// 2：每10分钟；
        /// 3：故障前后存储，正常时每小时存；默认3
        /// </summary>
        public int saveType { get; set; } = 3;
        public DateTime timeNew { get; set; } = DateTime.Now;
        public DateTime timeData { get; set; } = DateTime.Now;
        /// <summary>
        /// 保存数据库缓存
        /// </summary>
        public List<SaveInfo> saveInfos { get; set; } = new List<SaveInfo>();
        public int saveCount { get; set; } = 15;
        /// <summary>
        /// 接下来需要保存多少条数据
        /// </summary>
        public int numSave { get; set; } = 0;
        /// <summary>
        /// 新增保存告警到数据库信息
        /// </summary>
        /// <param name="saveInfo"></param>
        public void saveInfoAdd(SaveInfo saveInfo)
        {
            if (saveInfos.Count > (saveCount + 2))
            {
                saveInfos.RemoveRange(0, 1);
            }
            saveInfos.Add(saveInfo);
        }
    }
}
